package com.woniuxy.dao;

import com.woniuxy.dto.CarInsuranceDto;
import com.woniuxy.entity.CarInsurance;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface CarInsuranceMapper {
    /**
     * 条件查询分页查询所有
     *
     */
    List<CarInsuranceDto> findAll(Map<String,Object> condition);

    /**
     * 添加
     */
    @Insert("insert into car_insurance values(null,#{policyNumber},#{insuranceCompany},#{insuranceDate},#{deadlineDate},#{operatingMileage},#{insuranceState},#{carId})")
    int save(CarInsurance carInsurance);

    /**
     * 修改
     */
    int updateById(CarInsurance carInsurance);
    /**
     * 删除
     */
    @Delete("delete from car_insurance where id=#{id}")
    int deleteById(Integer id);
    /**
     * 批量删除
     */
    int deleteBatch(@Param("ids") String[] ids);

    /**
     * 批量添加数据
     */
    int insertBatch(List<CarInsuranceDto> carInsuranceList);
    /***
     *查询所有保险远程绑定
     */
    @Select("SELECT * FROM car_insurance ci RIGHT JOIN  car ON car.id = ci.car_id")
    List<CarInsuranceDto> carInsuranceList();
}
